package com.mzy.redis;

import io.lettuce.core.RedisClient;
import io.lettuce.core.RedisFuture;
import io.lettuce.core.RedisURI;
import io.lettuce.core.api.StatefulRedisConnection;
import io.lettuce.core.api.async.RedisAsyncCommands;
import io.lettuce.core.api.sync.RedisCommands;
import org.junit.jupiter.api.Test;

import java.util.List;

public class LettuceDemo {

    @Test
    public void lettuceTest() {
        RedisURI uri = RedisURI.builder()
                .redis("192.168.70.100")
                .withPort(6379)
                .withAuthentication("default", "mzy666")
                .build();
        RedisClient redisClient = RedisClient.create(uri);
        StatefulRedisConnection<String, String> connect = redisClient.connect();
        RedisCommands commands = connect.sync();
        List list = commands.keys("*");

        System.out.println(list);

        connect.close();
        redisClient.shutdown();
    }
}
